// pages/activity/group_exchange/main_page/goods_list/goods_list.js
var app = getApp();
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    groupId: {
      type: Number,
      value: null,
    }
  },

  /**
   * 组件的初始数据
   */
  data: {

  },

  /**
   * 组件生命周期函数，在组件实例进入页面节点树时执行
   */
  attached: function() {
    this.getNotice();
    this.getGoodsOptions();
  },

  /**
   * 组件的方法列表
   */
  methods: {
    /**
     * 获取滚动播放消息
     */
    getNotice: function () {
      app.Ajax({
        url: '/api/index.php?app=group&act=broadcast',
        success: (res) => {
          this.setData({
            notice: res
          })
        },
      })
    },

    /**
     * 免费拼团--商品
     */
    getGoodsOptions: function () {
      var goodsOption = {
        list_id: 'goods_list',
        url: '/api/index.php?app=category&act=group_goods',
        data: {
          group_id: this.data.groupId
        }
      }
      this.setData({
        goodsOption: goodsOption,
        pageHeight: app.globalData.pageHeight - 112,
      })
    },

    /**
     * 加载更多商品
     */
    loadMoreGoods: function (e) {
      this.setData({
        goodsList: e.detail.data,
      })
    },

    /**
     * 查看商品信息
     */
    lookGoodsInfo: function (e) {
      var id = e.detail.id;
      wx.navigateTo({
        url: '../../../goods_detail/goods_detail?group_id=' + this.data.groupId + '&goods_id=' + id,
      })
    }
  }
})
